package cn.tedu.spring.dibase;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;

@Repository

public class UserDao {
    /*
        @Value注解: 依赖注入DI,属性赋值；
        给基本类型属性赋值,比如字符串，数值类型

        可以添加位置：属性上,setter方法上
     */
    @Value("jdbc:mysql://localhost:3306/tedu")
    private String url;
    @Value("root")
    private String username;

    private String password;

    @Value("root")
    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "UserDao{" +
                "url='" + url + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}
